/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.qx.web;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.google.common.collect.Lists;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.common.utils.excel.ImportExcel;
import com.thinkgem.jeesite.modules.qx.dao.QxMatchDao;
import com.thinkgem.jeesite.modules.qx.entity.QxLeagueMatches;
import com.thinkgem.jeesite.modules.qx.entity.QxMatch;
import com.thinkgem.jeesite.modules.qx.entity.QxMatchHistory;
import com.thinkgem.jeesite.modules.qx.entity.QxTeam;
import com.thinkgem.jeesite.modules.qx.entity.QxTeamMatch;
import com.thinkgem.jeesite.modules.qx.service.QxMatchHistoryService;
import com.thinkgem.jeesite.modules.qx.service.QxMatchService;
import com.thinkgem.jeesite.modules.qx.service.QxTeamMatchService;
import com.thinkgem.jeesite.modules.qx.service.QxTeamService;
import com.thinkgem.jeesite.modules.qx.utils.QxCacheUtils;

/**
 * 单表生成Controller
 * @author zequs
 * @version 2017-08-23
 */
@Controller
@RequestMapping(value = "${adminPath}/qx/qxMatch")
public class QxMatchController extends BaseController {

	@Autowired
	private QxMatchService qxMatchService;
	
	@Autowired
	private QxMatchHistoryService qxMatchHistoryService;
	
	@Autowired
	private QxTeamService qxTeamService;
	
	@Autowired
	private QxTeamMatchService qxTeamMatchService;
	
	@ModelAttribute
	public QxMatch get(@RequestParam(required=false) String id) {
		QxMatch entity = null;
		if (StringUtils.isNotBlank(id)){
			entity = qxMatchService.get(id);
		}
		if (entity == null){
			entity = new QxMatch();
		}
		return entity;
	}
	
	@RequiresPermissions("qx:qxMatch:view")
	@RequestMapping(value = {"list", ""})
	public String list(QxMatch qxMatch, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<QxMatch> page = qxMatchService.findPage(new Page<QxMatch>(request, response), qxMatch); 
		model.addAttribute("page", page);
		return "modules/qx/qxMatchList";
	}

	@RequiresPermissions("qx:qxMatch:view")
	@RequestMapping(value = "form")
	public String form(QxMatch qxMatch, Model model) {
		model.addAttribute("qxMatch", qxMatch);
		return "modules/qx/qxMatchForm";
	}

	@RequiresPermissions("qx:qxMatch:edit")
	@RequestMapping(value = "save")
	public String save(QxMatch qxMatch, Model model, RedirectAttributes redirectAttributes) {
		if (!beanValidator(model, qxMatch)){
			return form(qxMatch, model);
		}
		String  a = "";
		qxMatchService.save(qxMatch);
		addMessage(redirectAttributes, "保存单表成功");
		return "redirect:"+Global.getAdminPath()+"/qx/qxMatch/?repage";
	}
	
	@RequiresPermissions("qx:qxMatch:edit")
	@RequestMapping(value = "delete")
	public String delete(QxMatch qxMatch, RedirectAttributes redirectAttributes) {
		qxMatchService.delete(qxMatch);
		addMessage(redirectAttributes, "删除单表成功");
		return "redirect:"+Global.getAdminPath()+"/qx/qxMatch/?repage";
	}
	/**
	 * 导入用户数据
	 * @param file
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("qx:qxMatch:excel")
    @RequestMapping(value = "import", method=RequestMethod.POST)
    public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) {
		if(Global.isDemoMode()){
			addMessage(redirectAttributes, "演示模式，不允许操作！");
			return "redirect:"+Global.getAdminPath()+"/qx/qxTeam/?repage";
		}
		try {
			int failureNum = 0;
			int successNum = 0;
			StringBuilder failureMsg = new StringBuilder();
			ImportExcel ei = new ImportExcel(file, 1, 0);
			List<QxMatch> list = ei.getDataList(QxMatch.class);
			for (QxMatch matches : list){
				List<String>  qxMatchIds = Lists.newArrayList();
				boolean flag = false;
				if (StringUtils.isNoneBlank(matches.getScore())) {
					if (matches.getScore().toUpperCase().contains("VS")) {
						matches.setStatus(0);
					} else {
						matches.setStatus(1);
						String[] scoures = matches.getScore().split("-"); 
						matches.setMainScore(Integer.parseInt(scoures[0]));
						matches.setGuestScore(Integer.parseInt(scoures[1]));
						QxTeam qxTeamMain = QxCacheUtils.geTeamByName(matches.getMainTeamName());
						if (qxTeamMain == null) {
							continue;
						}
						matches.setMainTeamId(qxTeamMain.getId());
						QxTeam qxTeamGuest = QxCacheUtils.geTeamByName(matches.getGuestTeamName());
						if (qxTeamMain == null) {
							continue;
						}
						matches.setGuestTeamId(qxTeamGuest.getId());
						if (!qxMatchIds.contains(matches.getMainTeamId())) {
							qxMatchIds.add(matches.getMainTeamId());
						}
						if (!qxMatchIds.contains(matches.getGuestTeamId())) {
							qxMatchIds.add(matches.getGuestTeamId());
						}
					}
				} else {
					failureMsg.append("比分为空，主队为：" + matches.getMainTeamName());
					failureNum++;
					continue;
				}
				if (StringUtils.isNoneBlank(matches.getLeagueMatchesName())) {
					QxLeagueMatches qxLeagueMatches = QxCacheUtils.getQxLeagueMatchesByName(matches.getLeagueMatchesName());
					if (null != qxLeagueMatches) {
						matches.setLeagueMatchesId(qxLeagueMatches.getId());
					}
				}
				QxTeam mainTeam = QxCacheUtils.geTeamByName(matches.getMainTeamName());
				QxTeam guestTeam = QxCacheUtils.geTeamByName(matches.getGuestTeamName());
				if ( null != mainTeam &&  null != guestTeam) {
					/*
					logger.error("联赛名错误，联赛名：{}没有找到", team.getLeagueName());
					failureNum++;
					failureMsg.append("联赛名：" + team.getLeagueName() + "导入错误," );
					*/
					matches.setMainTeamId(mainTeam.getId());
					matches.setGuestTeamId(guestTeam.getId());
				} else {
					failureMsg.append("主客队错误，主队为：" + matches.getMainTeamName() + "客队为：" + matches.getGuestTeamName());
					failureNum++;
					continue;
				}
				successNum++;
				qxMatchService.save(matches);
				if (matches.getStatus() == 1) {
					QxTeamMatch mTeam = new QxTeamMatch();
					mTeam.setMatchid(matches.getId());
					mTeam.setTeamid(matches.getMainTeamId());
					mTeam.setHomeType(1);
					if (matches.getMainScore() > matches.getGuestScore()) {
						mTeam.setResult(1);
					} else if (matches.getMainScore() == matches.getGuestScore()) {
						mTeam.setResult(2);
					} else if (matches.getMainScore() < matches.getGuestScore()) {
						mTeam.setResult(3);
					}
					mTeam.setOddsEven(matches.getOddsEven());
					mTeam.setOddsWin(matches.getOddsWin());
					mTeam.setOddsLose(matches.getOddsLose());
					mTeam.setWheel(matches.getWheel());
					mTeam.setLeagueid(mainTeam.getLeagueid());
					mTeam.setScore(matches.getMainScore());
					qxTeamMatchService.save(mTeam);
					
					QxTeamMatch gTeam = new QxTeamMatch();
					gTeam.setMatchid(matches.getId());
					gTeam.setTeamid(matches.getGuestTeamId());
					gTeam.setHomeType(0);
					if (matches.getMainScore() > matches.getGuestScore()) {
						gTeam.setResult(3);
					} else if (matches.getMainScore() == matches.getGuestScore()) {
						gTeam.setResult(2);
					} else if (matches.getMainScore() < matches.getGuestScore()) {
						gTeam.setResult(1);
					}
					gTeam.setOddsEven(matches.getOddsEven());
					gTeam.setOddsWin(matches.getOddsLose());
					gTeam.setOddsLose(matches.getOddsWin());
					gTeam.setWheel(matches.getWheel());
					gTeam.setLeagueid(guestTeam.getLeagueid());
					gTeam.setScore(matches.getGuestScore());
					qxTeamMatchService.save(gTeam);
				}
				
				for (String teamId : qxMatchIds) {
					QxMatch qxMatch = new QxMatch();
					qxMatch.setTeamId(teamId);
					
					//异常x次数
					int normalUnusualCount = 0;
					//极端异常Y次数
					int extremelyUnusualCunt = 0;
					//稳定异常Z次数
					int stableUnusualCunt = 0;
					
					List<QxMatch>  matchs = qxMatchService.lastSixMatch(qxMatch);
					for (QxMatch sixMatch : matchs) {
						QxMatchHistory qxMatchHistory = new QxMatchHistory();
						qxMatchHistory.setTeamid(teamId);
						QxTeam qTeam = QxCacheUtils.geTeam(teamId);
						qxMatchHistory.setLeagueid(qTeam.getLeagueid());
						qxMatchHistory.setWheel(sixMatch.getWheel());
						int team = 0;
						int score = 0;
						
						//主客队
						if (sixMatch.getGuestTeamId().equals(teamId)) {
							qxMatchHistory.setHomeType(1);
							team = 2;
						} else if (sixMatch.getMainTeamId().equals(teamId)) {
							qxMatchHistory.setHomeType(0);
							team = 1;
						} else {
							qxMatchHistory.setHomeType(2);
						}
						
						//主队和客队的大小关系
						if (sixMatch.getMainScore() > sixMatch.getGuestScore()) {
							score = 1;
						} else if (sixMatch.getMainScore() < sixMatch.getGuestScore()) {
							score = 2;
						} else if (sixMatch.getMainScore() == sixMatch.getGuestScore()) {
							score = 3;
						} 
						
						if (score == 3) {
							qxMatchHistory.setResult(2);
						} else if (score == 0 || team ==0) {
							qxMatchHistory.setResult(4);
						} else if (score == team) {
							qxMatchHistory.setResult(1);
						} else if (score != team) {
							qxMatchHistory.setResult(3);
							QxTeam mainQxTeam = QxCacheUtils.geTeam(sixMatch.getMainTeamId());
							QxTeam guestQxTeam = QxCacheUtils.geTeam(sixMatch.getGuestTeamId());
							if ((team == 2 && (mainQxTeam.getRank() - guestQxTeam.getRank()) >= 3 && (mainQxTeam.getRank() - guestQxTeam.getRank()) < 5)
								|| (team == 1 && (guestQxTeam.getRank() - mainQxTeam.getRank()) > 3 && (guestQxTeam.getRank() - mainQxTeam.getRank()) < 3)) {
								qxMatchHistory.setNormalUnusual(1);
								normalUnusualCount++;
							}
							if ((team == 2 && (mainQxTeam.getRank() - guestQxTeam.getRank()) >= 5)
									|| (team == 1 && (guestQxTeam.getRank() - mainQxTeam.getRank()) > 5)) {
								qxMatchHistory.setExtremelyUnusual(1);
								extremelyUnusualCunt++;
							}
							//稳定异常Z
						}
						qxMatchHistoryService.save(qxMatchHistory);
					}
					if (normalUnusualCount != 0 || extremelyUnusualCunt != 0 || stableUnusualCunt != 0) {
						 QxTeam qxTeam = QxCacheUtils.geTeam(teamId);
						 if (normalUnusualCount != 0) {
							qxTeam.setNormalUnusual(qxTeam.getNormalUnusual() + normalUnusualCount);
						 }
						 if (extremelyUnusualCunt != 0) {
							 qxTeam.setExtremelyUnusual(qxTeam.getExtremelyUnusual() + extremelyUnusualCunt);
						 }
						 if (stableUnusualCunt != 0) {
							 qxTeam.setStableException(qxTeam.getStableException() + stableUnusualCunt);
						 }
						 qxTeamService.save(qxTeam);
						 QxCacheUtils.putCache("team_key"+qxTeam.getId(), qxTeam);
						 QxCacheUtils.putCache("team_name_key"+qxTeam.getName(), qxTeam);
					}
				}
			}
			if (failureNum>0){
				failureMsg.append("，失败 "+failureNum+" 条数据，导入信息如下：");
			}
			addMessage(redirectAttributes, "已成功导入 "+successNum+" 条数据"+failureMsg);
		} catch (Exception e) {
			addMessage(redirectAttributes, "导入用户失败！失败信息："+e.getMessage());
		}
		return "redirect:"+Global.getAdminPath()+"/qx/qxMatch/?repage";
    }
	/**
	 * 导入用户数据
	 * @param file
	 * @param redirectAttributes
	 * @return
	 */
	@RequiresPermissions("qx:qxMatch:excel")
    @RequestMapping(value = "import", method=RequestMethod.POST)
    public String importFile2(MultipartFile file, RedirectAttributes redirectAttributes) {
		if(Global.isDemoMode()){
			addMessage(redirectAttributes, "演示模式，不允许操作！");
			return "redirect:"+Global.getAdminPath()+"/qx/qxTeam/?repage";
		}
		try {
			int failureNum = 0;
			int successNum = 0;
			StringBuilder failureMsg = new StringBuilder();
			ImportExcel ei = new ImportExcel(file, 1, 0);
			List<QxMatch> list = ei.getDataList(QxMatch.class);
			for (QxMatch matches : list){
				List<String>  qxMatchIds = Lists.newArrayList();
				boolean flag = false;
				if (StringUtils.isNoneBlank(matches.getScore())) {
					if (matches.getScore().toUpperCase().contains("VS")) {
						matches.setStatus(0);
					} else {
						matches.setStatus(1);
						String[] scoures = matches.getScore().split("-"); 
						matches.setMainScore(Integer.parseInt(scoures[0]));
						matches.setGuestScore(Integer.parseInt(scoures[1]));
						QxTeam qxTeamMain = QxCacheUtils.geTeamByName(matches.getMainTeamName());
						if (qxTeamMain == null) {
							continue;
						}
						matches.setMainTeamId(qxTeamMain.getId());
						QxTeam qxTeamGuest = QxCacheUtils.geTeamByName(matches.getGuestTeamName());
						if (qxTeamMain == null) {
							continue;
						}
						matches.setGuestTeamId(qxTeamGuest.getId());
						if (!qxMatchIds.contains(matches.getMainTeamId())) {
							qxMatchIds.add(matches.getMainTeamId());
						}
						if (!qxMatchIds.contains(matches.getGuestTeamId())) {
							qxMatchIds.add(matches.getGuestTeamId());
						}
						matches.setLeagueMatchesId(qxTeamMain.getLeagueid());
						successNum++;
						
						//主场
						qxMatchService.save(matches);
						QxTeamMatch mTeam = new QxTeamMatch();
						mTeam.setMatchid(matches.getId());
						mTeam.setTeamid(matches.getMainTeamId());
						mTeam.setHomeType(1);
						if (matches.getMainScore() > matches.getGuestScore()) {
							mTeam.setResult(1);
						} else if (matches.getMainScore() == matches.getGuestScore()) {
							mTeam.setResult(2);
						} else if (matches.getMainScore() < matches.getGuestScore()) {
							mTeam.setResult(3);
						}
						mTeam.setOddsEven(matches.getOddsEven());
						mTeam.setOddsWin(matches.getOddsWin());
						mTeam.setOddsLose(matches.getOddsLose());
						mTeam.setWheel(matches.getWheel());
						mTeam.setLeagueid(qxTeamMain.getLeagueid());
						mTeam.setScore(matches.getMainScore());
						qxTeamMatchService.save(mTeam);
						
						//客场
						QxTeamMatch gTeam = new QxTeamMatch();
						gTeam.setMatchid(matches.getId());
						gTeam.setTeamid(matches.getGuestTeamId());
						gTeam.setHomeType(0);
						if (matches.getMainScore() > matches.getGuestScore()) {
							gTeam.setResult(3);
						} else if (matches.getMainScore() == matches.getGuestScore()) {
							gTeam.setResult(2);
						} else if (matches.getMainScore() < matches.getGuestScore()) {
							gTeam.setResult(1);
						}
						gTeam.setOddsEven(matches.getOddsEven());
						gTeam.setOddsWin(matches.getOddsLose());
						gTeam.setOddsLose(matches.getOddsWin());
						gTeam.setWheel(matches.getWheel());
						gTeam.setLeagueid(qxTeamGuest.getLeagueid());
						gTeam.setScore(matches.getGuestScore());
						qxTeamMatchService.save(gTeam);
						
					}
				} else {
					failureMsg.append("比分为空，主队为：" + matches.getMainTeamName());
					failureNum++;
					continue;
				}
				
				QxTeam mainTeam = QxCacheUtils.geTeamByName(matches.getMainTeamName());
				QxTeam guestTeam = QxCacheUtils.geTeamByName(matches.getGuestTeamName());
				if ( null != mainTeam &&  null != guestTeam) {
					matches.setMainTeamId(mainTeam.getId());
					matches.setGuestTeamId(guestTeam.getId());
				} else {
					failureMsg.append("主客队错误，主队为：" + matches.getMainTeamName() + "客队为：" + matches.getGuestTeamName());
					failureNum++;
					continue;
				}
				
				qxMatchService.save(matches);
				if (matches.getStatus() == 1) {
					QxTeamMatch mTeam = new QxTeamMatch();
					mTeam.setMatchid(matches.getId());
					mTeam.setTeamid(matches.getMainTeamId());
					mTeam.setHomeType(1);
					if (matches.getMainScore() > matches.getGuestScore()) {
						mTeam.setResult(1);
					} else if (matches.getMainScore() == matches.getGuestScore()) {
						mTeam.setResult(2);
					} else if (matches.getMainScore() < matches.getGuestScore()) {
						mTeam.setResult(3);
						if (guestTeam.getRank() - mainTeam.getRank() > 3) {
							//设置状态异常x
						}
						if ((guestTeam.getStrength()==1 && mainTeam.getStrength()==3) ||((guestTeam.getStrength()==2 && mainTeam.getStrength()==3 &&(guestTeam.getRank() - mainTeam.getRank()>5)))) {
							//设置状态异常y
						}
						if (guestTeam.getRank() > mainTeam.getRank()) {
							//设置状态异常z
						}
					}
					mTeam.setOddsEven(matches.getOddsEven());
					mTeam.setOddsWin(matches.getOddsWin());
					mTeam.setOddsLose(matches.getOddsLose());
					mTeam.setWheel(matches.getWheel());
					mTeam.setLeagueid(mainTeam.getLeagueid());
					mTeam.setScore(matches.getMainScore());
					qxTeamMatchService.save(mTeam);
					
					QxTeamMatch gTeam = new QxTeamMatch();
					gTeam.setMatchid(matches.getId());
					gTeam.setTeamid(matches.getGuestTeamId());
					gTeam.setHomeType(0);
					if (matches.getMainScore() > matches.getGuestScore()) {
						gTeam.setResult(3);
						if (mainTeam.getRank() - guestTeam.getRank() > 3) {
							//设置状态异常x
						}
						if ((guestTeam.getStrength()==1 && mainTeam.getStrength()==3) ||((guestTeam.getStrength()==2 && mainTeam.getStrength()==3 &&(mainTeam.getRank() - guestTeam.getRank()>5)))) {
							//设置状态异常y
						}
						if (mainTeam.getRank() > guestTeam.getRank()) {
							//设置状态异常z
						}
					} else if (matches.getMainScore() == matches.getGuestScore()) {
						gTeam.setResult(2);
					} else if (matches.getMainScore() < matches.getGuestScore()) {
						gTeam.setResult(1);
					}
					gTeam.setOddsEven(matches.getOddsEven());
					gTeam.setOddsWin(matches.getOddsLose());
					gTeam.setOddsLose(matches.getOddsWin());
					gTeam.setWheel(matches.getWheel());
					gTeam.setLeagueid(guestTeam.getLeagueid());
					gTeam.setScore(matches.getGuestScore());
					qxTeamMatchService.save(gTeam);
					
				}
				/*
				for (String teamId : qxMatchIds) {
					QxMatch qxMatch = new QxMatch();
					qxMatch.setTeamId(teamId);
					
					//异常x次数
					int normalUnusualCount = 0;
					//极端异常Y次数
					int extremelyUnusualCunt = 0;
					//稳定异常Z次数
					int stableUnusualCunt = 0;
					
					List<QxMatch>  matchs = qxMatchService.lastSixMatch(qxMatch);
					for (QxMatch sixMatch : matchs) {
						QxMatchHistory qxMatchHistory = new QxMatchHistory();
						qxMatchHistory.setTeamid(teamId);
						QxTeam qTeam = QxCacheUtils.geTeam(teamId);
						qxMatchHistory.setLeagueid(qTeam.getLeagueid());
						qxMatchHistory.setWheel(sixMatch.getWheel());
						int team = 0;
						int score = 0;
						
						//主客队
						if (sixMatch.getGuestTeamId().equals(teamId)) {
							qxMatchHistory.setHomeType(1);
							team = 2;
						} else if (sixMatch.getMainTeamId().equals(teamId)) {
							qxMatchHistory.setHomeType(0);
							team = 1;
						} else {
							qxMatchHistory.setHomeType(2);
						}
						
						//主队和客队的大小关系
						if (sixMatch.getMainScore() > sixMatch.getGuestScore()) {
							score = 1;
						} else if (sixMatch.getMainScore() < sixMatch.getGuestScore()) {
							score = 2;
						} else if (sixMatch.getMainScore() == sixMatch.getGuestScore()) {
							score = 3;
						} 
						
						if (score == 3) {
							qxMatchHistory.setResult(2);
						} else if (score == 0 || team ==0) {
							qxMatchHistory.setResult(4);
						} else if (score == team) {
							qxMatchHistory.setResult(1);
						} else if (score != team) {
							qxMatchHistory.setResult(3);
							QxTeam mainQxTeam = QxCacheUtils.geTeam(sixMatch.getMainTeamId());
							QxTeam guestQxTeam = QxCacheUtils.geTeam(sixMatch.getGuestTeamId());
							if ((team == 2 && (mainQxTeam.getRank() - guestQxTeam.getRank()) >= 3 && (mainQxTeam.getRank() - guestQxTeam.getRank()) < 5)
								|| (team == 1 && (guestQxTeam.getRank() - mainQxTeam.getRank()) > 3 && (guestQxTeam.getRank() - mainQxTeam.getRank()) < 3)) {
								qxMatchHistory.setNormalUnusual(1);
								normalUnusualCount++;
							}
							if ((team == 2 && (mainQxTeam.getRank() - guestQxTeam.getRank()) >= 5)
									|| (team == 1 && (guestQxTeam.getRank() - mainQxTeam.getRank()) > 5)) {
								qxMatchHistory.setExtremelyUnusual(1);
								extremelyUnusualCunt++;
							}
							//稳定异常Z
						}
						qxMatchHistoryService.save(qxMatchHistory);
					}
					if (normalUnusualCount != 0 || extremelyUnusualCunt != 0 || stableUnusualCunt != 0) {
						 QxTeam qxTeam = QxCacheUtils.geTeam(teamId);
						 if (normalUnusualCount != 0) {
							qxTeam.setNormalUnusual(qxTeam.getNormalUnusual() + normalUnusualCount);
						 }
						 if (extremelyUnusualCunt != 0) {
							 qxTeam.setExtremelyUnusual(qxTeam.getExtremelyUnusual() + extremelyUnusualCunt);
						 }
						 if (stableUnusualCunt != 0) {
							 qxTeam.setStableException(qxTeam.getStableException() + stableUnusualCunt);
						 }
						 qxTeamService.save(qxTeam);
						 QxCacheUtils.putCache("team_key"+qxTeam.getId(), qxTeam);
						 QxCacheUtils.putCache("team_name_key"+qxTeam.getName(), qxTeam);
					}
				}
				 */
			}
			if (failureNum>0){
				failureMsg.append("，失败 "+failureNum+" 条数据，导入信息如下：");
			}
			addMessage(redirectAttributes, "已成功导入 "+successNum+" 条数据"+failureMsg);
		} catch (Exception e) {
			addMessage(redirectAttributes, "导入用户失败！失败信息："+e.getMessage());
		}
		return "redirect:"+Global.getAdminPath()+"/qx/qxMatch/?repage";
    }
	
	
	public void aa(QxMatch qxMatch) {
		
	}
}